<?php
namespace Home\Model;
use Think\Model;
class SupplierModel extends Model {
	
	public function supplier_list($pageNo,$pageSize,$where="1")
	{    
		 $supplier=M('supplier');
		 $count['count']=$supplier->where($where)->count();
		 $count['countpage']=ceil($count['count']/$pageSize);
		 if($pageNo>=$count['countpage']){
			$pageNo=$count['countpage'];
		 }
		 if($pageNo<=0){
		 	$pageNo=1;
		 }
		 
		 $supplier_list=$supplier->where($where)->limit(($pageNo-1)*$pageSize,$pageSize)->select();
		 
		 $count['pageSize']=$pageSize;
		 $count['pageNo']=$pageNo;
		 $count['num']=$count['countpage']-4;
		
		 $result['supplier_list']=$supplier_list;
		 $result['count']=$count;
		 $result['data']=$data;
		 return $result;
		 
	}
	
	public function buyer_list($where){
		$supplier = M("supplier");
		$result = $supplier->field("buyer")->where($where)->find();
		return $result;
	}
	
	
	public function buyer($for_short){
		$where['for_short'] = $for_short;
		$supplier = M("supplier");
		$result = $supplier->field("buyer")->where($where)->find();
		return $result;
	}
	

	
}
?>